<?php
class UserAdmin extends Module{
	function UserAdmin($row){
		define('BAN_NICK_DATE',7);
		CGlobal::$website_title = 'Quản lý thành viên';
		Module::Module($row);
		
		if(User::have_permit(ADMIN_USER)){			
			switch(Url::get('cmd')){
				case 'lockdie':	//Khoá vĩnh viễn
					$id=(int)Url::get('id',0);
					if($id){
						$user = User::getUser($id);
						
						if($user){	
							DB::update('user',array('block_time'=>-1),'id='.$id);
							
							DB::insert('user_lock',array('time'=>TIME_NOW,'user_id'=>$id,'user_name'=>$user['user_name'],'type'=>3,'admin_id'=>User::id(),'admin_name'=>User::user_name()));
							User::getUser($id,0,1);
						}
					}
					Url::redirect_url(Url::build_all(array('chk_id','del_all','cmd','id','lock_die_all','hd_ac')));
					break;
				case 'delete':	
					Item::delete_item(Url::get('id'));
					Url::redirect_url(Url::build_all(array('chk_id','del_all','cmd','id','lock_die_all','hd_ac'),"cmd=item_list"));
					break;	
				case 'del_cache':
					$id=(int)Url::get('id',0);
					if($id){												
						User::getUser($id,0,1);											
					}	
					Url::redirect_url(Url::build_all(array('chk_id','del_all','cmd','id','lock_die_all','hd_ac')));
					break;	
				case 'del_avatar':									
					$user=DB::select('user',(int)Url::get('id'));
					if($user){
						if($user['avatar_url']){					
							AZLib::ftp_image_delete_file($user['avatar_url'],$user['img_server']);
							DB::update('user',array('avatar_url'=>'','img_server'=>0),'id='.$user['id']);
							User::getUser($user['id'],0,1);
						}
					}
					Url::redirect_url(Url::build_all(array('chk_id','del_all','cmd','id','lock_die_all','hd_ac')));
					break;	
				case 'item_list':					
					require_once 'forms/item_list.php';
					$this->add_form(new ItemListForm());
					break;
				case 'user_log':					
					require_once 'forms/user_log.php';
					$this->add_form(new UserLogForm());
					break;	
				case 'detail':					
					require_once 'forms/UserDetail.php';
					$this->add_form(new UserDetailForm());
					break;	
				case 'add':					
					require_once 'forms/UserAdd.php';
					$this->add_form(new UserAddForm());
					break;	
				case 'edit':					
					require_once 'forms/UserEdit.php';
					$this->add_form(new UserEditForm());
					break;	
				default:
					require_once 'forms/UserAdmin.php';
					$this->add_form(new ListUserAdminForm());
					break;
			}
		}
		else{
			Url::access_denied();
		}
	}
}
?>
